// 用户模块的API方法集合

import request from '@/utils/request'
import store from '@/store'

/*
export const login = function(params){
    return request({
        method: 'POST',
        url: '/app/v1_0/authorizations',
        data: params
    })
}
*/
export const login = data => {
  return request({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data 
  })
}
export const getCode = mobile => {
  return request({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}

export const getUserInfo = () => {
  console.log(`Bearer ${store.state.user.token}`)
  return request({
    method: 'GET',
    url: '/app/v1_0/user',
    // 发送请求头数据
    headers: {
      Authorization: `Bearer ${store.state.user.token}`
    }
  })
}
/**
 * 关注用户
 */
export const addFollow = target => {
  return request({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target
    }
  })
}
/**
 * 取消关注用户
 */
export const deleteFollow = target => {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${target}`
  })
}
